package com.bob.clan.wxconnector.config;

import com.bob.clan.wxconnector.entity.Mp;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 微信基本服务的URL，与页面授权的服务不同
 */
@Data
@Component
@ConfigurationProperties(prefix = "wx-server-url")
public class WxServerConfig {
    private String AccessTokenUrl;
    private String CreateQrUrl;
    private String RidUrl;
    private String ModelMsgUrl;

    public String getMpAccessTokenUrl(Mp mp) {
        return this.AccessTokenUrl.replace("YOUR_APPID", mp.getAppid()).replace("YOUR_APPSECRET", mp.getSecret());
    }

    public String getUrlByToken(String url,String token){
        return url.replace("YOUR_ACCESS_TOKEN", token);
    }
}
